<!doctype html>
<html>
<body>
    <div style="display:flex;align-items:center;">
        <img src="../../data/test_sunrise.jpg" id="sunrise_img" width="20%">
    </div>
    <div>
        <h3>result:</h3>
        <textarea id="result" rows="30" cols="100"></textarea>
    </div>

    <script src="../../../flycv.js" type="text/javascript"></script>
    <script type="text/javascript">
        let resultHtml = document.getElementById("result");

        fcv.then((fcv) => {
            // 读取图像，构造mat数据
            let srcU8 = fcv.imread("sunrise_img");

            // todo：subtract当前只支持f32和f64数据
            let srcF32 = new fcv.Mat();
            srcU8.convertTo(srcF32, fcv.FCVImageType.PKG_RGBA_F32, 1.0, 0);

            let dst = new fcv.Mat();
            let scalar = [5, 55, 0, 55];
            fcv.subtract(srcF32, scalar, dst);

            // 可视化
            resultHtml.append(dst.data());

            // 内存回收
            srcU8.delete();
            srcF32.delete();
            dst.delete();
        });
    </script>
</body>
</html>